-module(pt_game_start_b002).
-include("pt.hrl").

-export([new/0,from_binary/1,to_binary/1,to_binary/2,get_id/0]).

get_id()-> 16#B002.

new()->#pt_game_start{}.

from_binary(Binary) -> 
	{Binary1,Data1} = lib_protocol:from_binary(Binary,uint32),
	{Binary2,Data2} = lib_protocol:from_binary(Binary1,uint32),
	{Binary3,Data3} = lib_protocol:from_binary(Binary2,uint32),
	{Binary4,Data4} = lib_protocol:from_binary(Binary3,uint32),
	{Binary5,Data5} = lib_protocol:from_binary(Binary4,uint16),
	{Binary6,Data6} = lib_protocol:from_binary(Binary5,uint8),
	{Binary7,Data7} = lib_protocol:from_binary(Binary6,uint8),
	{_Binary,Data8} = lib_protocol:from_binary(Binary7,{list,game_player_from_binary}),
	#pt_game_start{
		zhuang_index = Data1,
		cur_index = Data2,
		cur_status = Data3,
		cur_time = Data4,
		qp_num = Data5,
		game_times = Data6,
		max_game_times = Data7,
		room_players = Data8
	}.

to_binary(Pt) -> to_binary(Pt,0).
to_binary(Pt,Seq) -> 
	Data1 = lib_protocol:to_binary(Pt#pt_game_start.zhuang_index,uint32),
	Data2 = lib_protocol:to_binary(Pt#pt_game_start.cur_index,uint32),
	Data3 = lib_protocol:to_binary(Pt#pt_game_start.cur_status,uint32),
	Data4 = lib_protocol:to_binary(Pt#pt_game_start.cur_time,uint32),
	Data5 = lib_protocol:to_binary(Pt#pt_game_start.qp_num,uint16),
	Data6 = lib_protocol:to_binary(Pt#pt_game_start.game_times,uint8),
	Data7 = lib_protocol:to_binary(Pt#pt_game_start.max_game_times,uint8),
	Data8 = lib_protocol:to_binary(Pt#pt_game_start.room_players,{list,game_player_to_binary}),
	GetData = <<Data1/binary,Data2/binary,Data3/binary,Data4/binary,Data5/binary,Data6/binary,Data7/binary,Data8/binary>>,
	lib_protocol:make_pt(GetData,get_id(),Seq).

